// ---------------------------------------------------------------------------------------------------------------------
//   Copyright (c) SRT Solutions 2009. All rights reserved.
// ---------------------------------------------------------------------------------------------------------------------

//JRW: actually everything in this file so far is CC0 by JRW
namespace SRTSolutions.Elevate
{
    using System;
    /// <summary>
    /// What, there wasn't a place for putting things on everything?
    /// </summary>
    public static class ObjectExtensions
    {
        /// <summary>
        /// Wraps the eventdata in event args.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="eventData">The event data.</param>
        /// <returns></returns>
        public static EventArgs<T> WrappedInEventArgs<T>(this T eventData)
        {
            return new EventArgs<T>(eventData);
        }

        /// <summary>
        /// Pass param as the param to action.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="param"></param>
        /// <param name="action"></param>
        /// <remarks>Sometimes it is nicer to write code in an Extension method way.</remarks>
        public static void PipeTo<T>(this T param, Action<T> action)
        {
            action(param);
        }


        /// <summary>
        /// Pass param as the param to func.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="T2"></typeparam>
        /// <param name="param"></param>
        /// <param name="func"></param>
        /// <remarks>Sometimes it is nicer to write code in an Extension method way.</remarks>
        public static T2 PipeTo<T,T2>(this T param, Func<T,T2> func)
        {
            return func(param);
        }
    }
}
